package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.mapper.OrderMapper;
import com.itheima.mapper.SetMealMapper;
import com.itheima.pojo.CheckItem;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    /**
     * 分页查询
     */
    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        //开启分页查询
        PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        //查询当前页结果
        List<CheckItem> rows = orderMapper.findPage();
        //查询总记录数
        Long total = orderMapper.countAll();
        //封装返回结果
        return new PageResult(total,rows);
    }
    /**
     * 修改状态
     */
    @Override
    public void update(Order order) {
        orderMapper.update(order.getId(),order.getOrderStatus());
    }
}
